package com.thlws.consul.gateway.routes;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 *  功能等同 yml 中配置
 *  routes:
 *   - id: xyz_route
 *     uri: http://www.360.com
 *     predicates:
 *       - Path=/xyz/**
 *
 * @author  Hanley 2019-06-19
 */
@Component
public class MyRoute {


    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("my_route_001", r -> r.path("/help")
                    .uri("http://www.shanhaidian.com"))
                .build();
    }
}
